home *** CD-ROM | disk | FTP | other *** search
- MsgBox is a simple class module that provides (hopefully) a
- useful bit of functionality. The VB MsgBox function has had some
- idiosyncrasies in the past which may still exist in VB4 (though
- I'm not sure of it). Under VB3 I used a wrapper function around
- the API MessageBox function as a replacement. Now I've ported it
- to VB4 and made it an object (i.e. class). Creating new versions
- should be easy as well. You can replace the MessageBox call with
- your own form and code, make message boxes that time-out, add
- animation capabilities, use custom icons, etc.
-
- This software, and the included source code, is FREEWARE.
-
- You may use it as you see fit in your own projects but you may
- not re-sell the original or a derivative. If you redistribute
- it you must include this disclaimer and all original copyright
- notices.
-
- No warranty is inferred or implied, as always seems to be the
- case with software these days. Use at your own risk. Keep away
- from small children. Don't exceed recommended dosage. I'm not
- liable, I'm not liable, I'm not liable.
-
- I'd love to see people improve upon this work. Please keep me
- posted if you do. If you should happen to change the behavior
- in a derivative version please change the class name so as not
- to cause problems with existing code.
-
- Enjoy!
-
- --Gregg Irwin [72450,676]
-
- --------------------------------------------------------------
- Possible Enhancements
-
- I'm thinking about the HelpFile and Context options that
- the VB MsgBox function now offers. This would require
- using the MessageBoxIndirect API function which isn't
- available under Win16 (AFAIK). MessageBoxIndirect requires
- a callback function to process Help commands so, if you
- want to add HelpFile and Context properties your best bet
- might be to use the VB MsgBox function internally rather
- than the API calls.
-
- MessageBoxEx could also be used to add multi-language
- support.
-
- --------------------------------------------------------------
- What's New? 01/06/96
-
- The MsgBox class is unchanged. The sample project, though,
- now inlcudes a code generator that will generate code to
- paste into your projects. This lets you use the sample
- project as a message box designer.
-
- The generated code is placed into a text box so you can
- review it and copy it to the clipboard to paste into your
- projects. Since all the source is included you can tweak
- the code generator to match your standards and style.
-
- The code generator isn't a great piece of sample code
- because I put it together very quickly. It can certainly
- be improved. Thanks to Bill Antonacchio for the impetus.
-
- --------------------------------------------------------------
-
- Q. How do I use it?
-
- A. It's easy.
-
- 1. Dim a variable to hold the message box.
-
- Example: Dim MB As New clsMsgBox
-
- 2. Set the Title of the message box.
-
- Example: MB.Title = "Reformat Drive"
-
- 3. Set the Message of the message box.
-
- Example: MB.Message = "Are you sure you want to do that?"
-
- 4. Set the Style of the message box.
-
- Example: MB.Style = vbYesNo + vbQuestion
-
- 5. Display the message box and handle the return value.
-
- Example: Dim Rtn as Integer
- Rtn = MB.ShowModal
-
- --------------------------------------------------------------
-
- Q. What if I hate setting all those properties? I'd rather
- use it like the MsgBox function in VB.
-
- A. No problem. The ShowModal method takes all the required
- settings as optional parameters.
-
- Example: Rtn = MB.ShowModal(Msg, Style, Title, (FormX.HWnd))
-
- Note: The final HWnd parameter is used by the API
- MessageBox function.
-
- --------------------------------------------------------------
-
- Q. Why a class module?
-
- A. Why not? It has a defined interface. It provides
- encapsulation. It allows you to create multiple instances
- easily. It can be used as an OLE server. It can raise
- errors effectively. 'nuff said?
-
- --------------------------------------------------------------
-
- Q. What if I have suggestions, requests, or improvements?
-
- A. Send them to me and I'll get back to you as quickly as I
- can. Hopefully we can make it a community effort and build
- up a good library of tools that we can all draw upon.
-
- --------------------------------------------------------------
-
- Q. What if it has a bug in it that costs me millions of
- dollars?
-
- A. Re-read the disclaimer and let me know about the bug
- please.<g>
-
- --------------------------------------------------------------
-
-